/**
 * 
 */
package game;

/**
 * @author Jean-Baptiste BORIC
 *
 */
public class Building {
	private BuildingType type;
	private Player player;
	private int x;
	private int y;
	
	/**
	 * @param type
	 * @param x
	 * @param y
	 */
	public Building(BuildingType type, int x, int y) {
		super();
		this.setType(type);
		this.setCoordinates(x, y);
	}
	
	public Building(BuildingType type, Player player, int x, int y) {
		super();
		this.setPlayer(player);
		this.setType(type);
		this.setCoordinates(x, y);
	}

	/**
	 * @return Building type
	 */
	public BuildingType getType() {
		return type;
	}
	
	/**
	 * @param type Building type
	 */
	public void setType(BuildingType type) {
		this.type = type;
	}
	
	/**
	 * @return Building's player
	 */
	public Player getPlayer() {
		return player;
	}
	
	/**
	 * @param player Building's player
	 */
	public void setPlayer(Player player) {
		this.player = player;
	}
	
	/**
	 * @return X position
	 */
	public int getX() {
		return x;
	}
	
	/**
	 * @return Y position
	 */
	public int getY() {
		return y;
	}
	
	/**
	 * @param x X position
	 * @param y Y position
	 */
	public void setCoordinates(int x, int y) {
		if(x < 0 || y < 0) {
			throw new IllegalArgumentException("Invalid coordinates");
		}
		this.x = x;
		this.y = y;
	}

	@Override
	public String toString() {
		return type.getName() + "\t" + player.getID() + "\t" + x + "\t" + y;
	}	
}
